<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>image-overlay-hover</title>
    <style>
        .hover-box {
            background-color: #000;
            color: #fff;
            display: inline-block;
            margin: 8px;
            max-width: 320px;
            min-width: 240px;
            overflow: hidden;
            position: relative;
            width: 100%;
            text-align: center;
        }
        .hover-box * {
            box-sizing: border-box;
            transition: all .45s ease;
        }
        .hover-box::before,.hover-box::after {
            content:"";
            background-color: rgba(0,0,0,.5);
            border-top: 32px solid rgba(0,0,0,.5);
            border-bottom: 32px solid rgba(0,0,0,.5);
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            transition: all .3s ease;
            z-index: 1;
            opacity: 0;
            transform: scaleY(2);
        }
        .hover-box .hover-box-img {
            vertical-align: top;
            max-width: 100%;
            backface-visibility: hidden;
        }
        .hover-box .hover-box-content {
            position: absolute;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            align-items: center;
            z-index: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            line-height: 1.1em;
            opacity: 0;
            z-index: 2;
            transition-delay: .1s;
            font-size: 24px;
            font-family: sans-serif;
            font-weight: 400;
            letter-spacing: 1px;
            text-transform: uppercase;
        }
        .hover-box:hover::before,
        .hover-box:hover::after {
            transform: scale(1);
            opacity: 1;
        }
        .hover-box:hover > .hover-box-img {
            opacity: .7;
        }
        .hover-box:hover .hover-box-content {
            opacity: 1;
        }
    </style>
</head>
<body>
    <figure class="hover-box">
        <img src="https://www.eveningwater.com/img/segmentfault/10.png" alt="图片加载中" class="hover-box-img">
        <figcaption class="hover-box-content">
            <h3 class="hover-box-content-title">Lorem <br>Ipsum</h3>
        </figcaption>
    </figure>
</body>
</html>